package br.com.controlehr.view;

import java.awt.Color;

import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.UIManager;

public class MainUI {
	private JFrame janela;
	private JPanel painelPrincipal;
	private JMenuCustom menuCustom;
	

	public static void main(String[] args) {
		new MainUI().montaTela();
	}

	private void montaTela() {
		preparaJanela();
		preparaPainelPrincipal();
		mostraJanela();

	}
	
	private void preparaPainelPrincipal() {
		painelPrincipal = new JPanel();
		painelPrincipal.setBackground(Color.white);
		this.janela.add(painelPrincipal);
	}
	

	private void preparaJanela() {
		this.janela = new JFrame("Controle de Horas");
		try {
			// Metal
			UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
		} catch (Exception e) {
			throw new IllegalArgumentException(
					"Deu pau na hora de trocar o look and feel");
		}
		BufferedImage image;
		try {
			image = ImageIO.read(new File("../ControleHrs/icons/clock.png"));
			janela.setIconImage(image);
		} catch (IOException e) {
			e.printStackTrace();
		} 
		menuCustom =  new JMenuCustom();
		janela.setJMenuBar(menuCustom);
		janela.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	}

	private void mostraJanela() {
		this.janela.pack();
		this.janela.setSize(800,600);
		this.janela.setVisible(true);
	}

	public JPanel getPainelPrincipal() {
		return painelPrincipal;
	}
}